

#include "Engine.h"
#include "Entity.h"


Engine::Engine(u32 maxEntities)
	:layerManager(maxEntities)
{

}

Engine::~Engine()
{
	//Todo:  free all entities
}

void Engine::AddEntity(Entity *ent)
{
	newEntityList.push_back(ent);
}


void Engine::MergeEntityLists()
{
	if (newEntityList.size()){
		for(u32 i = 0; i<newEntityList.size();i++){
			entityList.push_back(newEntityList[i]);
			layerManager.Append(newEntityList.at(i)->GetLayer());
		}
		newEntityList.clear();				
	}
}

void Engine::Update()
{
	MergeEntityLists();
	for(u32 i = 0; i< entityList.size(); i++){
		entityList.at(i)->Update();
	}
}
	

		